What is @babel/plugin-transform-numeric-separator?
The @babel/plugin-transform-numeric-separator package allows developers to use numeric separators in their JavaScript code to improve readability of numeric literals. This plugin transforms these numeric literals with separators into standard numeric literals that can be understood by JavaScript engines that do not support this ES2021 feature.
What are @babel/plugin-transform-numeric-separator's main functionalities?
Transforming large numeric literals
Improves readability of large numeric literals by allowing underscores as separators.
1000000000 // Before transformation
1_000_000_000 // After using @babel/plugin-transform-numeric-separator
Support for various numeric types
Allows numeric separators in binary, octal, and hexadecimal literals, enhancing clarity in different numeric systems.
0b1010_0101_1001 // binary
0o2_3_5_7 // octal
0xdead_beef // hexadecimal
Other packages similar to @babel/plugin-transform-numeric-separator
typescript
TypeScript, a superset of JavaScript, supports numeric separators directly in the language without needing a transformation plugin. However, TypeScript offers a much broader set of features beyond numeric separators, including type checking and interfaces.
esbuild
esbuild is a fast JavaScript bundler and minifier that supports transforming modern JavaScript features, including numeric separators, for compatibility with older environments. While it provides similar functionality in terms of numeric separators, esbuild is more focused on bundling and building performance.
@babel/plugin-transform-numeric-separator
Remove numeric separators from Decimal, Binary, Hex and Octal literals
See our website @babel/plugin-transform-numeric-separator for more information.
Install
Using npm:
npm install --save-dev @babel/plugin-transform-numeric-separator
or using yarn:
yarn add @babel/plugin-transform-numeric-separator --dev